using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;

using ILRuntime.CLR.TypeSystem;
using ILRuntime.CLR.Method;
using ILRuntime.Runtime.Enviorment;
using ILRuntime.Runtime.Intepreter;
using ILRuntime.Runtime.Stack;
using ILRuntime.Reflection;
using ILRuntime.CLR.Utils;
using System.Linq;

namespace ILRuntime.Runtime.Generated
{
    unsafe class huqiang_Communication_DataPacker_Binding
    {
        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
        {
            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
            MethodBase method;
            FieldInfo field;
            Type[] args;
            Type type = typeof(huqiang.Communication.DataPacker);
            args = new Type[]{};
            method = type.GetMethod("get_Usage", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, get_Usage_0);
            args = new Type[]{};
            method = type.GetMethod("get_Remain", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, get_Remain_1);
            args = new Type[]{};
            method = type.GetMethod("get_Delay", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, get_Delay_2);
            args = new Type[]{typeof(System.Byte[]), typeof(System.Int32), typeof(System.UInt16)};
            method = type.GetMethod("AddRecvMsg", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, AddRecvMsg_3);
            args = new Type[]{typeof(System.Byte[]), typeof(System.Int32), typeof(System.UInt16)};
            method = type.GetMethod("HandleRecv", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, HandleRecv_4);
            args = new Type[]{typeof(System.Int32)};
            method = type.GetMethod("ClearTimeOut", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, ClearTimeOut_5);
            args = new Type[]{typeof(System.UInt32), typeof(System.Byte)};
            method = type.GetMethod("RemoveSendMsg", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, RemoveSendMsg_6);
            args = new Type[]{typeof(System.Byte[]), typeof(System.UInt16)};
            method = type.GetMethod("AddSendMsg", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, AddSendMsg_7);
            args = new Type[]{typeof(System.Byte[]), typeof(System.Int32), typeof(System.Int32)};
            method = type.GetMethod("FirstSend", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, FirstSend_8);
            args = new Type[]{typeof(System.Byte[]), typeof(System.Int32), typeof(System.Int32)};
            method = type.GetMethod("Dispatch", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, Dispatch_9);
            args = new Type[]{};
            method = type.GetMethod("Clear", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, Clear_10);

            field = type.GetField("Msg_Normal", flag);
            app.RegisterCLRFieldGetter(field, get_Msg_Normal_0);
            app.RegisterCLRFieldBinding(field, CopyToStack_Msg_Normal_0, null);
            field = type.GetField("Msg_Success", flag);
            app.RegisterCLRFieldGetter(field, get_Msg_Success_1);
            app.RegisterCLRFieldBinding(field, CopyToStack_Msg_Success_1, null);
            field = type.GetField("Msg_Failed", flag);
            app.RegisterCLRFieldGetter(field, get_Msg_Failed_2);
            app.RegisterCLRFieldBinding(field, CopyToStack_Msg_Failed_2, null);
            field = type.GetField("Msg_Heart", flag);
            app.RegisterCLRFieldGetter(field, get_Msg_Heart_3);
            app.RegisterCLRFieldBinding(field, CopyToStack_Msg_Heart_3, null);
            field = type.GetField("FragmentSize", flag);
            app.RegisterCLRFieldGetter(field, get_FragmentSize_4);
            app.RegisterCLRFieldSetter(field, set_FragmentSize_4);
            app.RegisterCLRFieldBinding(field, CopyToStack_FragmentSize_4, AssignFromStack_FragmentSize_4);
            field = type.GetField("FragmentDataSize", flag);
            app.RegisterCLRFieldGetter(field, get_FragmentDataSize_5);
            app.RegisterCLRFieldSetter(field, set_FragmentDataSize_5);
            app.RegisterCLRFieldBinding(field, CopyToStack_FragmentDataSize_5, AssignFromStack_FragmentDataSize_5);
            field = type.GetField("max", flag);
            app.RegisterCLRFieldGetter(field, get_max_6);
            app.RegisterCLRFieldSetter(field, set_max_6);
            app.RegisterCLRFieldBinding(field, CopyToStack_max_6, AssignFromStack_max_6);


            app.RegisterCLRCreateDefaultInstance(type, () => new huqiang.Communication.DataPacker());
            app.RegisterCLRCreateArrayInstance(type, s => new huqiang.Communication.DataPacker[s]);

            args = new Type[]{};
            method = type.GetConstructor(flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, Ctor_0);

        }


        static StackObject* get_Usage_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            huqiang.Communication.DataPacker instance_of_this_method = (huqiang.Communication.DataPacker)typeof(huqiang.Communication.DataPacker).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.Usage;

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static StackObject* get_Remain_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            huqiang.Communication.DataPacker instance_of_this_method = (huqiang.Communication.DataPacker)typeof(huqiang.Communication.DataPacker).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.Remain;

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static StackObject* get_Delay_2(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            huqiang.Communication.DataPacker instance_of_this_method = (huqiang.Communication.DataPacker)typeof(huqiang.Communication.DataPacker).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.Delay;

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static StackObject* AddRecvMsg_3(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 4);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.UInt16 @time = (ushort)ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Int32 @len = ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            System.Byte[] @buf = (System.Byte[])typeof(System.Byte[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 4);
            huqiang.Communication.DataPacker instance_of_this_method = (huqiang.Communication.DataPacker)typeof(huqiang.Communication.DataPacker).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.AddRecvMsg(@buf, @len, @time);

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static StackObject* HandleRecv_4(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 4);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.UInt16 @time = (ushort)ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Int32 @len = ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            System.Byte[] @dat = (System.Byte[])typeof(System.Byte[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 4);
            huqiang.Communication.DataPacker instance_of_this_method = (huqiang.Communication.DataPacker)typeof(huqiang.Communication.DataPacker).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.HandleRecv(@dat, @len, @time);

            return __ret;
        }

        static StackObject* ClearTimeOut_5(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Int32 @timeout = ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            huqiang.Communication.DataPacker instance_of_this_method = (huqiang.Communication.DataPacker)typeof(huqiang.Communication.DataPacker).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.ClearTimeOut(@timeout);

            return __ret;
        }

        static StackObject* RemoveSendMsg_6(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Byte @part = (byte)ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.UInt32 @msgId = (uint)ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            huqiang.Communication.DataPacker instance_of_this_method = (huqiang.Communication.DataPacker)typeof(huqiang.Communication.DataPacker).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.RemoveSendMsg(@msgId, @part);

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method ? 1 : 0;
            return __ret + 1;
        }

        static StackObject* AddSendMsg_7(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 3);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.UInt16 @time = (ushort)ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Byte[] @dat = (System.Byte[])typeof(System.Byte[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            huqiang.Communication.DataPacker instance_of_this_method = (huqiang.Communication.DataPacker)typeof(huqiang.Communication.DataPacker).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.AddSendMsg(@dat, @time);

            return __ret;
        }

        static StackObject* FirstSend_8(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 4);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Int32 @len = ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Int32 @startindex = ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            System.Byte[] @dat = (System.Byte[])typeof(System.Byte[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 4);
            huqiang.Communication.DataPacker instance_of_this_method = (huqiang.Communication.DataPacker)typeof(huqiang.Communication.DataPacker).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.FirstSend(@dat, @startindex, @len);

            return __ret;
        }

        static StackObject* Dispatch_9(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 4);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Int32 @len = ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.Int32 @start = ptr_of_this_method->Value;

            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
            System.Byte[] @buf = (System.Byte[])typeof(System.Byte[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 4);
            huqiang.Communication.DataPacker instance_of_this_method = (huqiang.Communication.DataPacker)typeof(huqiang.Communication.DataPacker).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.Dispatch(@buf, @start, @len);

            return __ret;
        }

        static StackObject* Clear_10(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            huqiang.Communication.DataPacker instance_of_this_method = (huqiang.Communication.DataPacker)typeof(huqiang.Communication.DataPacker).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.Clear();

            return __ret;
        }


        static object get_Msg_Normal_0(ref object o)
        {
            return huqiang.Communication.DataPacker.Msg_Normal;
        }

        static StackObject* CopyToStack_Msg_Normal_0(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = huqiang.Communication.DataPacker.Msg_Normal;
            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static object get_Msg_Success_1(ref object o)
        {
            return huqiang.Communication.DataPacker.Msg_Success;
        }

        static StackObject* CopyToStack_Msg_Success_1(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = huqiang.Communication.DataPacker.Msg_Success;
            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static object get_Msg_Failed_2(ref object o)
        {
            return huqiang.Communication.DataPacker.Msg_Failed;
        }

        static StackObject* CopyToStack_Msg_Failed_2(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = huqiang.Communication.DataPacker.Msg_Failed;
            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static object get_Msg_Heart_3(ref object o)
        {
            return huqiang.Communication.DataPacker.Msg_Heart;
        }

        static StackObject* CopyToStack_Msg_Heart_3(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = huqiang.Communication.DataPacker.Msg_Heart;
            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static object get_FragmentSize_4(ref object o)
        {
            return huqiang.Communication.DataPacker.FragmentSize;
        }

        static StackObject* CopyToStack_FragmentSize_4(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = huqiang.Communication.DataPacker.FragmentSize;
            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static void set_FragmentSize_4(ref object o, object v)
        {
            huqiang.Communication.DataPacker.FragmentSize = (System.UInt16)v;
        }

        static StackObject* AssignFromStack_FragmentSize_4(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.UInt16 @FragmentSize = (ushort)ptr_of_this_method->Value;
            huqiang.Communication.DataPacker.FragmentSize = @FragmentSize;
            return ptr_of_this_method;
        }

        static object get_FragmentDataSize_5(ref object o)
        {
            return huqiang.Communication.DataPacker.FragmentDataSize;
        }

        static StackObject* CopyToStack_FragmentDataSize_5(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = huqiang.Communication.DataPacker.FragmentDataSize;
            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static void set_FragmentDataSize_5(ref object o, object v)
        {
            huqiang.Communication.DataPacker.FragmentDataSize = (System.UInt16)v;
        }

        static StackObject* AssignFromStack_FragmentDataSize_5(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.UInt16 @FragmentDataSize = (ushort)ptr_of_this_method->Value;
            huqiang.Communication.DataPacker.FragmentDataSize = @FragmentDataSize;
            return ptr_of_this_method;
        }

        static object get_max_6(ref object o)
        {
            return ((huqiang.Communication.DataPacker)o).max;
        }

        static StackObject* CopyToStack_max_6(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Communication.DataPacker)o).max;
            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static void set_max_6(ref object o, object v)
        {
            ((huqiang.Communication.DataPacker)o).max = (System.Int32)v;
        }

        static StackObject* AssignFromStack_max_6(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.Int32 @max = ptr_of_this_method->Value;
            ((huqiang.Communication.DataPacker)o).max = @max;
            return ptr_of_this_method;
        }



        static StackObject* Ctor_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* __ret = ILIntepreter.Minus(__esp, 0);

            var result_of_this_method = new huqiang.Communication.DataPacker();

            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }


    }
}
